<template lang="pug">
  div#user
        img(:src="userData.imgurl")
        div
            div 
                span.bold {{userData.name}}
                router-link(:to="{ path: '/personal/records' }") 消费记录
            div 已登录：{{userData.phone}}
        a(@click="logout") 退出登录

        form#form(action="/filorga-wechat/login/loginout" method="post" ref="logoutForm")
          input(name="uid",:value="userData.uid")
          input(name="type",:value="userData.type")
</template>
<script>
export default {
  computed: {
    userData() {
      return window.data;
    }
  },
  methods: {
    logout() {
      // this.$api.v1
      //   .login_loginout_post({
      //     data: { uid: this.userData.uid, type: this.userData.type }
      //   })
      //   .then(resp => {
      //     userData = {}
      //   });
      this.$refs.logoutForm.submit();
    }
  }
};
</script>

<style lang="stylus" scoped>
#user {
  background-color: #fff;
  color: #666;
  font-size: 0.28rem;
  line-height: 0.5rem;
  display: flex;
  padding: 0.3rem;
  justify-content: space-between;
  align-items: center;

  >img {
    border-radius: 50%;
    padding: 0.05rem;
    background-color: #666;
    height: 1rem;
    width: 1rem;
    margin-right: 0.3rem;
  }

  >div {
    flex-grow: 1;

    .bold {
      color: #000;
      margin-right: 0.1rem;
      font-weight: bold;
    }
  }

  a {
    color: #ac0e0e;
  }

  #form{
    display: none;
  }
}
</style>

